class Solution {
    public int searchInsert(int[] nums, int target) {

        int left=0;
        int right=nums.length-1;
        int mid=left+(right-left)/2;
        while(left<=right){
            if(target==nums[mid]){
                return mid;
            }
            if(target<nums[mid]){
                right=mid-1;
            }else{
                left=mid+1;
            }
            mid=(left)+(right-left)/2;
        }
        return left;
    }
}
public class Test {
    public static void main(String[] args) {
        int[] nums={1,2,5,6};
        Solution solution=new Solution();
       int ret= solution.searchInsert(nums,5);
        System.out.println(ret);
    }
}